import baseRequest from "@/axios/baseRequest"
// import config from "@/config/config"
export default {

  addNewStation(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/stationManage/stationInfo/insertStationInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  updateStation(params) {
    return new Promise((resolve, reject) => {
      baseRequest.put("/bigdata-pv-backend/stationManage/stationInfo/updateStationInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getList(params) {
    let paramStr = ''
    for (const key in params) {
      if (params[key]) {
        paramStr += [key] + '=' + params[key] + '&'
      }
    }
    const url = paramStr ? "/bigdata-pv-backend/stationManage/stationInfo/pageStationInfoList?" + paramStr : "/bigdata-pv-backend/stationManage/stationInfo/pageStationInfoList"
    return new Promise((resolve, reject) => {
      baseRequest.get(url).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  deleteStation(params) {
    return new Promise((resolve, reject) => {
      baseRequest.delete("/bigdata-pv-backend/stationManage/stationInfo/deleteStationInfo", {
        data: params.ids
      }).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getCompanyList() {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/stationManage/listCompanyOption").then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  uploadStation(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/stationManage/stationInfo/uploadInsertStationInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  downloadTemplate() {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/stationManage/stationInfo/downloadTemplate").then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  stationResultSearch(params) {
    let str = ''
    for (let key in params) {
      if (params[key]) {
        str += [key] + '=' + params[key] + '&'
      }
    }
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/diagtask/requery/getByStation?" + str).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  pvModuleResultSearch(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/diagtask/requery/getByModuleInfo", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  pvModuleResultDetailSearch(params) {
    return new Promise((resolve, reject) => {
      baseRequest.post("/bigdata-pv-backend/diagtask/details/getDiagResultDetails", params).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  },
  getOriginFiles(params) {
    return new Promise((resolve, reject) => {
      baseRequest.get("/bigdata-pv-backend/diagtask/details/getOriFileNameList?inspectTaskCode=" + params.inspectTaskCode).then(data => {
        resolve(data)
      }).catch(e => {
        reject(e)
      })
    })
  }
}
